#ifndef __CMIOT_H__
#define __CMIOT_H__


#include "zos_config.h"


#ifdef BOARD_USING_CMIOT

#include "zos_def.h"

#define CMIOT_SERVER_IP "183.230.40.40"	//重庆接入机
//#define CMIOT_SERVER_IP "192.168.24.100"  //专用APN接入机
#define CMIOT_LIFE_TIME 3000
#define CMIOT_OBJECT_MAX_NUM 10
#define CMIOT_INSTANCE_MAX_NUM 10

enum  cmiot_value_type
{
	cmiot_value_string=1,
	cmiot_value_opaque,
	cmiot_value_integer,
	cmiot_value_float,
	cmiot_value_bool
};

enum cmiot_state_type
{
	cmiot_state_init=0,
	cmiot_state_unreg,
	cmiot_state_close,
	cmiot_state_run,
	cmiot_state_success=4,
	cmiot_state_close_init=0,
	cmiot_state_close_start,
	cmiot_state_update_init=10,
	cmiot_state_update_failure,
	cmiot_state_update_success,
	cmiot_state_update_timeout=14,
	cmiot_state_update_need=18,
	cmiot_state_result_read_success=1,
	cmiot_state_result_write_success,
	cmiot_state_result_Bad_Request=11,
	cmiot_state_result_Unauthorized,
	cmiot_state_result_Not_Found,
	cmiot_state_result_Method_Not_Allowed,
	cmiot_state_result_Not_Acceptable
};

union cmiot_value
{
	zos_uint8_t *string_value;
	int int_value;
	float float_value;
	zos_bool_t bool_value;
};

typedef union cmiot_value *cmiot_value_t;

struct cmiot_stream
{
	int objid;
	int inscount;
	int rescount;
	int atts;
	int acts;
	int insid;
	int resid;
	int valuetype;
	int msgid;
	int read_state;
	int write_state;
	int exec_state;
	int observe_notify_state;
	int user_state;
	char bitmap[CMIOT_INSTANCE_MAX_NUM];
};

typedef struct cmiot_stream *cmiot_stream_t;

cmiot_stream_t cmiot_object_init(int objid,int insid,int resid,zos_uint32_t inscount,char *bitmap,zos_uint32_t atts,zos_uint32_t acts,zos_uint32_t type);

int cmiot_init_environment(void);
zos_err_t cmiot_create_instance(void);
zos_err_t cmiot_add_object(void);
zos_err_t cmiot_open(void);
zos_err_t cmiot_close(void);
zos_err_t cmiot_update_time(int flag);
zos_err_t cmiot_quick_start(void);
zos_err_t cmiot_notify(cmiot_stream_t stream,int len,cmiot_value_t data,int index,int flag);
zos_err_t cmiot_notify_with_ack(cmiot_stream_t stream,int len,cmiot_value_t data,int index,int flag);
zos_err_t cmiot_get_connect(void);
zos_err_t cmiot_get_observe_notify(cmiot_stream_t stream);
zos_err_t cmiot_get_object_read(cmiot_stream_t stream);
zos_err_t cmiot_get_object_write(cmiot_stream_t stream);
zos_err_t cmiot_get_object_exec(cmiot_stream_t stream);
zos_err_t cmiot_read_rsp(zos_uint32_t msgid,zos_uint32_t result,cmiot_stream_t stream,zos_uint32_t len,cmiot_value_t data,zos_uint32_t index,zos_uint32_t flag);


#endif


#endif


